#include<bits/stdc++.h>
using namespace std;
const int maxn = 205;
int T;
int n,a[maxn],b[maxn],ans=-100000;
int work()
{
    int c[205];
    for(int i=2;i<=n;i++)
    {
        for(int j=i-1;j>=1;j--)
        {
            if(b[i]==b[j])
            {
                
                if(a[i]==a[j])
                {
                    c[i]=a[i];
                }
                else c[i]=0;
                goto wmyr;

            }
            else c[i]=0;
        }
        wmyr:;
    }
    int res=0;
    for(int i=2;i<=n;i++)
        res+=c[i];
    return res;
}
void dfs(int x,int co)
{
    b[x]=co;
    if(x==n)
    {
        ans=max(ans,work());
        return;
    }
    dfs(x+1,1);
    dfs(x+1,0);
    return;
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--)
    {
        cin>>n;
        memset(b,0,sizeof(b));
        ans=-100000;
        for(int i=1;i<=n;i++) cin>>a[i];
        dfs(1,0);
        dfs(1,1);
        cout<<ans<<endl;
    }

    return 0;
}